import React, { useRef, useEffect } from "react";

const MyInput = React.forwardRef((props, ref) => {

  return (
    <input type="text" ref={ref} {...props} />
  )
})

export const RefDemo = () => {
  const inputRef = useRef()
  useEffect(() => {
    inputRef.current.focus()
    inputRef.current.value = "hello world"
  }, [])

  return (
    <MyInput ref={inputRef} placeholder="请输入" />
  )
}